home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Aminet 30
/
Aminet 30 (1999)(Schatztruhe)[!][Apr 1999].iso
/
Aminet
/
biz
/
dopus
/
SoundOpus.lha
/
Opus5
/
ARexx
/
SoundOpus.dopus5
Wrap
Text File
|
1999-01-01
|
13KB
|
534 lines
/* $VER: SoundOpus.dopus5 2.0 (1.01.99)
©1999 by Piotr Bieniek (adam@chemul.uni.lodz.pl)
DOPUS5.5+ AREXX Script for all kinds of soundplaying
with ProgressBar-GUI and timecounter.
Requirements:
* DOPUS 5.5
* MPEGA 3.3 (for playing MPEG-Audio)
* GMPlay 1.3 (for playing MIDI)
* Play16 1.8 (for playing samples)
* RexxMaster (ARexx) running
* rexxsupport.library somewhere in LIBS:
* Break and List commands in C:
* PIPE: device mounted
* MPEG-Audio filetype installed in Opus (use this one included in
the package, or set ID of your own MPEG-Audio filetype to "MPA")
* MIDI filetype installed in Opus (use this one included in the
package, or set ID of your own MIDI filetype to "MIDI")
* a set of sample format filetypes installed in Opus (use these
included in the package, or set IDs of your own filetypes to
"WAVE", "VOC", "AIFF", "MAUD", "8SVX", "AU" and "CDDA")
Description:
Integrates Dopus and MPEGA/GMPlay/Play16 for the best functionality
with playing all kinds of audio. Displays Name/Soundformat/Time
in a Dopus progress window. Shows the runtime on a
progressbar and a timecounter.
Installation:
As button or menuitem:
<AREXX> Dopus5:ARexx/SoundOpus.dopus5 {Qp}
For Filetype-startup (doubleclick start):
<AREXX> Dopus5:ARexx/SoundOpus.dopus5 {Qp} {Ql} {o}
Before you start using the script you must configure it (paths for
MPEGA, GMPlay and Play16 executables must be given).
Usage:
Select all sound files you want to listen and start SoundOpus.
If you want to stop playing a file press the abort button.
When you stop a file in the first five seconds, script will
be completely aborted.
You can also select directories. This script will look for all kinds
of sound files there (and in further subdirectories) and will add them
to the list of sounds to be played.
Configuration:
Names of MPEGA, GMPlay and Play16 executables must be given in the
following variables:
mpegaexe - name (with path) for MPEGA executable file.
gmplayexe - name (with path) for GMPlay executable file.
play16exe - name (with path) for Play16 executable file.
You can also configure these programs for your needs by changing
other variables:
mpegamode - CLI arguments, which are passed to MPEGA.
gmplaymode - CLI arguments, which are passed to GMPlay.
play16mode - CLI arguments, which are passed to Play16.
*/
OPTIONS RESULTS
/* change this to configure the script */
mpegaexe="MPEGA"
mpegamode=""
gmplayexe="Work:Music/GMPlay/GMPlay"
gmplaymode=""
play16exe="Play16"
play16mode="PRE OUT=Paula8"
PARSE ARG portname' 'handle' 'filename
ADDRESS VALUE portname
if Exists('T:SoundOpusRunning') then
do
DOPUS REQUEST '"SoundOpus script is already running" OK'
exit
end
else
do
Open('file', 'T:SoundOpusRunning', 'w')
Close('file')
end
if ~Show(Libraries,"rexxsupport.library") then AddLib("rexxsupport.library",0,-30,0)
if handle="" then
do
LISTER QUERY SOURCE
if rc~=0 then
do
DOPUS REQUEST '"You must have a source lister" OK'
Delete('T:SoundOpusRunning')
exit
end
else
parse var result handle .
LISTER SET handle BUSY ON
LISTER QUERY handle PATH
pfad=result
cnt=0
LISTER QUERY handle SELENTRIES STEM entries.
if entries.count>0 then
do
do j=0 to entries.count-1
LISTER QUERY handle ENTRY '"'entries.j'"' STEM entry
if entry.type<0 then
do
DOPUS GETFILETYPE '"'pfad||entries.j'"' ID
if result="MPA" | result="MIDI" | result="CDDA" | result="WAVE" | result="VOC" | result="AIFF" | result="MAUD" | result="8SVX" | result="AU" then
do
filetypes.cnt=result
files.cnt=entries.j
cnt=cnt+1
LISTER SELECT handle '"'entries.j'"' OFF
end
else if result="binary" then
do
in=entries.j||'0a'x" was not recognized as a sound file"
dopus request '"'in'"' "CDDA|Skip"
if rc=1 then
do
filetypes.cnt="CDDA"
files.cnt=entries.j
cnt=cnt+1
LISTER SELECT handle '"'entries.j'"' OFF
end
end
end
else if entry.type>0 then
do
ADDRESS COMMAND 'List >T:SoundOpusList ALL FILES PAT ~(#?.info) LFORMAT %p%s "'pfad||entries.j'"'
Open('list', 'T:SoundOpusList', 'r')
do forever
fname=ReadLn('list')
if eof('list') then leave
DOPUS GETFILETYPE '"'fname'"' ID
if result="MPA" | result="MIDI" | result="CDDA" | result="WAVE" | result="VOC" | result="AIFF" | result="MAUD" | result="8SVX" | result="AU" then
do
filetypes.cnt=result
files.cnt=Substr(fname, Length(pfad)+1)
cnt=cnt+1
end
end
Close('list')
Delete('T:SoundOpusList')
LISTER SELECT handle '"'entries.j'"' OFF
end
end
end
files.count=cnt
end
else
do
LISTER QUERY handle PATH
pfad=result
files.0=compress(filename,'"')
files.count=1
DOPUS GETFILETYPE '"'pfad||files.0'"' ID
filetypes.0=result
end
if files.count=0 then
do
LISTER REFRESH handle
LISTER SET handle BUSY OFF
DOPUS REQUEST '"No sound files selected" OK'
Delete('T:SoundOpusRunning')
exit
end
LISTER SET handle BUSY OFF
LISTER REFRESH handle
DOPUS PROGRESS NAME FILE INFO BAR ABORT
prhandle=result
DOPUS PROGRESS prhandle TITLE 'Playing...'
do j=0 to files.count-1
DOPUS PROGRESS prhandle BAR files.count j+1
DOPUS PROGRESS prhandle NAME Substr(files.j, Lastpos('/', files.j)+1)
DOPUS PROGRESS prhandle FILE 1 0
if filetypes.j="MPA" then
do
if ~(PlayMPEG(files.j)) then leave
end
else if filetypes.j="MIDI" then
do
if ~(PlayMIDI(files.j)) then leave
end
else if filetypes.j="CDDA" then
do
if ~(PlaySample(files.j, 1)) then leave
end
else
do
if ~(PlaySample(files.j, 0)) then leave
end
end
DOPUS PROGRESS prhandle OFF
Delete('T:SoundOpusRunning')
exit
PlayMPEG: procedure expose pfad prhandle mpegaexe mpegamode
DOPUS PROGRESS prhandle INFO "Loading MPEG file / 00:00 / 00:00"
filename='"'pfad||Arg(1)'"'
ADDRESS COMMAND 'Run >T:mpegacli "'mpegaexe'" 'mpegamode' -T 'filename' >PIPE:mpegaout'
Open('cli', 'T:mpegacli', 'r')
process=ReadLn('cli')
parse var process '[CLI 'process']'
Close('cli')
Delete('T:mpegacli')
Open('mpegaout','PIPE:mpegaout', 'r')
do until string=""
if eof('mpegaout') then leave
string=ReadLineMPEG('mpegaout')
end
do until index(string, "File Type:")>0
if eof('mpegaout') then leave
string=ReadLineMPEG('mpegaout')
end
if ~eof('mpegaout') then
do
parse var string dummy"MPEG"mtype" "dummy"kbps "freq
mpgmode="MPEG"mtype" "freq
string=ReadLineMPEG('mpegaout')
parse var string dummy": "pm":"ps
ptotal=pm*60+ps
secs=0
DOPUS PROGRESS prhandle FILE ptotal 0
end
do forever
if eof('mpegaout') then leave
time=ReadCh('mpegaout',29)
if index(time,"err")>0 then
do
dopus request "MPEGA reports an error:"'0a'x||time
leave
end
time=left(right(time,10),5)
if time="" then leave
else parse var time min':'secs
secs=min*60+secs
DOPUS PROGRESS prhandle INFO mpgmode" / "pm":"ps" / "time
DOPUS PROGRESS prhandle FILE ptotal secs
DOPUS PROGRESS prhandle ABORT
if result then
do
ADDRESS COMMAND 'C:Break 'process' >NIL:'
if secs<6 then do
Close('mpegaout')
return 0
end
leave
end
end
Close('mpegaout')
return 1
ReadLineMPEG: procedure
chn = Arg(1)
line = ''
do until eof(chn)
chr = Readch(chn, 1)
if (Verify(chr, '0a'x, 'm')>0) | (Verify(chr, '0d'x, 'm')>0) then leave
if Verify(chr, '1b'x, 'm')>0 then
do
esc=Readch(chn, 3)
if esc="[22" then Readch(chn, 1)
end
else
line=line||chr
end
return line
PlayMIDI: procedure expose pfad prhandle gmplayexe gmplaymode
DOPUS PROGRESS prhandle INFO "Loading MIDI file / 00:00 / 00:00"
filename='"'pfad||Arg(1)'"'
ADDRESS COMMAND 'Run >T:gmplaycli "'gmplayexe'" 'gmplaymode' VERBOSE 'filename' >PIPE:gmplayout'
Open('cli', 'T:gmplaycli', 'r')
process=Readln('cli')
parse var process '[CLI 'process']'
Close('cli')
Delete('T:gmplaycli')
Open('gmplayout','PIPE:gmplayout', 'r')
Readch('gmplayout',210)
do forever
if eof('gmplayout') then leave
iin=ReadLineMIDI('gmplayout')
if pos("MIDI Mode : ",iin)>0 then
do
parse var iin "MIDI Mode : "format" "dummy
Readch('gmplayout',434)
end
else if pos("Length : ",iin)>0 then
do
parse var iin "Length : "pm":"ps" "dummy
ptotal=pm*60+ps
zpm=pm
if length(pm)<2 then zpm="0"pm
Readch('gmplayout',350)
end
else if pos("(",iin)>0 then
do
parse var iin dummy"'"sname"'"dummy
DOPUS PROGRESS prhandle INFO "Loading '"sname"'"
Readch('gmplayout',20)
end
else if pos("Time: ",iin)>0 then leave
DOPUS PROGRESS prhandle ABORT
if result then
do
ADDRESS COMMAND 'Break 'process' >NIL:'
Close('gmplayout')
return 0
end
end
linelen=length(iin)+1
do forever
if eof('gmplayout') then leave
if pos("Finished.",iin)>0 then leave
else if pos("Time:",iin)>0 then
do
mt=right(left(iin,7),2)
st=right(left(iin,10),2)
zmt=mt
if left(mt,1)=" " then
do
mt=right(mt,1)
zmt="0"mt
end
secs=mt*60+st
DOPUS PROGRESS prhandle INFO format" / "zpm":"ps" / "zmt":"st
DOPUS PROGRESS prhandle FILE ptotal secs
end
DOPUS PROGRESS prhandle ABORT
if result then
do
ADDRESS COMMAND 'Break 'process' >NIL:'
if secs<6 then
do
Close('gmplayout')
return 0
end
leave
end
iin=Readch('gmplayout',linelen)
end
Close('gmplayout')
return 1
ReadLineMIDI: procedure
chn=Arg(1)
line=''
do until eof(chn)
chr = Readch(chn, 1)
if (Verify(chr, '0a'x, 'm')>0) | (Verify(chr, '0d'x, 'm')>0) then leave
if Verify(chr, '1b'x, 'm')>0 then esc=Readch(chn, 2)
else
line=line||chr
end
return line
PlaySample: procedure expose pfad prhandle play16exe play16mode
DOPUS PROGRESS prhandle INFO "Loading sample / 00:00 / 00:00"
filename='"'pfad||Arg(1)'"'
if Arg(2) then ADDRESS COMMAND 'Run >T:play16cli "'play16exe'" 'play16mode' freq 44100 RAW bits 16 tracks 2 intel V=1 'filename' >PIPE:play16out'
else ADDRESS COMMAND 'Run >T:play16cli "'play16exe'" 'play16mode' V=1 'filename' >PIPE:play16out'
Open('cli', 'T:play16cli', 'r')
process=ReadLn('cli')
parse var process '[CLI 'process']'
Close('cli')
Delete('T:play16cli')
iin=""
format=" RAW"
Open('play16out','PIPE:play16out', 'r')
do forever
iin=ReadLineSample('play16out')
if index(iin,"Filetype")>0 then parse var iin "Filetype is"format"."
if index(iin,"tracks")>0 then parse var iin dummy": "tracks
if index(iin,"Bits")>0 then parse var iin dummy": "bits
if index(iin,"Compression")>0 then parse var iin dummy": "comp
if index(iin,"time")>0 then parse var iin dummy": "time
if index(iin,"frequency")>0 then parse var iin dummy": "freq
if index(iin,"playin")>0 then leave
if index(iin,"Error")>0 then
do
iin="Play16 reports an error:"||'0a'x||iin
dopus request '"'iin'"' "Oops"
Close('play16out')
return 1
end
end
Time('R')
parse var time pm":"ps
if tracks=1 then tracks="mono"
else tracks="stereo"
format=format" "bits"b-"tracks" "freq"Hz"
if ps>59 then
do
pm=pm+1
ps=ps-60
end
ptotal=pm*60+ps
if length(pm)<2 then pm="0"pm
if length(ps)<2 then ps="0"ps
DOPUS PROGRESS prhandle FILE ptotal 0
secs=0
azeit=0
mt=0
kst=0
do while secs<ptotal
st=secs-kst
if st>59 then
do
mt=mt+1
kst=kst+60
st=secs-kst
end
zmt=mt
if length(mt)<2 then zmt="0"mt
zst=st
if length(st)<2 then zst="0"st
DOPUS PROGRESS prhandle INFO format" / "pm":"ps" / "zmt":"zst
DOPUS PROGRESS prhandle FILE ptotal secs
DOPUS PROGRESS prhandle ABORT
if result then
do
ADDRESS COMMAND 'Break 'process' >NIL:'
if secs<6 then
do
Close('play16out')
return 0
end
leave
end
secs=Trunc(Time('E'))
if secs=azeit then
do
Delay(25)
secs=Trunc(Time('E'))
azeit=secs
end
end
if secs=ptotal then
do
DOPUS PROGRESS prhandle INFO format" / "pm":"ps" / "pm":"ps
DOPUS PROGRESS prhandle FILE ptotal secs
end
Close('play16out')
return 1
ReadLineSample:
PROCEDURE
chn = Arg(1)
line = ''
do until eof(chn)
chr = Readch(chn, 1)
if (Verify(chr, '0a'x, 'm')>0) then leave
line=line||chr
end
RETURN line